<?php namespace Common\Model;
use Hdphp\Model\Model;
class Tag extends Model{
	//指定表名
	protected $table='tag';
	//验证提交内容
	protected $validate=array(
		array('tname','required','标签名不能为空',3,3)
	);
	
	//添加
	public function store(){
		$data=explode("|",Q("post.tname"));
	    if(!$this->create()){
			return FALSE;
	    }else{
	    	foreach($data as $d){
	    		$this->add(['tname'=>$d]);
	    	}
			return TRUE;
	    }
	}
	//编辑
	public function edit($tid){
		if($this->create()){
			$this->where("tid={$tid}")->save();
			return TRUE;
		}else{
			return FALSE;
		}
	    
	}
}


 ?>
 















